﻿@model PagedList.IPagedList<DomenModel.Item>
@{
    ViewBag.Title = "AddItem";
}
Add Item<br />
Order Id#: @ViewBag.orderId<br />

<div>
    @using (Html.BeginForm())
    {
        <table class="filter-tabel">




            <tr>
                <td>
                    @Html.Label("Search for item by")

                </td>
                <th>
                    @Html.DropDownList("listSelectField", new SelectList(new string[] { "Item Name", "Item Description" }), new { @id = "combobox" })
                </th>
                <td>
                    @Html.TextBox("SearchString", ViewBag.CurrentFilter as string, new { @class = "item-drop-list border" })
                </td>

                <td style="text-align: right; padding-right: 30px;">
                    <input type="submit" name="action" value="Apply" class="buttons-blue" />
                </td>
            </tr>





        </table>
    }
    <div class="table">


        <table class="rounded-corner">
            <thead>
                <tr>
                    <th class="rounded-company">@Html.ActionLink("Item Name","AddItem", new {sortOrder=ViewBag.NameSortParm, currentFilter=ViewBag.CurrentFilter})</th>
                    <th >@Html.ActionLink("Item Description","AddItem", new {sortOrder = ViewBag.DescSortParm, currentFilter=ViewBag.CurrentFilter})</th>
                    <th class="rounded-q4"></th>
                </tr>
            </thead>
            <tbody>
                @foreach (var c in Model)
                {
                    <tr>
                        <td>@c.Name</td>
                        <td>@c.Description</td>
                        <td>@Html.ActionLink("Add","ItemQuantity",new { orderId = ViewBag.orderId, itemId = c.ItemId, name = c.Name , price = c.ItemPrice })</td>
                    </tr>
                
                }
                    @if (Model.Count != 10)
                    {
                        for (int i = 0; i <= 10 - Model.Count; i++)
                        {
                            <tr><td></td><td></td><td></td></tr>
                        }
                    }
            </tbody>
        </table>



    </div>
    <span id="numberOfPage">Page #: @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)
    of @Model.PageCount</span>
<div class="pagination">

     
    @if (Model.HasPreviousPage)
    {
        @Html.ActionLink("first", "AddItem", new { page = 1, sortOrder = ViewBag.CurrentSort, currentFilter=ViewBag.CurrentFilter, orderId = ViewBag.orderId })
        @Html.Raw(" ");
        @Html.ActionLink("< prev", "AddItem", new { page = Model.PageNumber - 1, sortOrder = ViewBag.CurrentSort, currentFilter=ViewBag.CurrentFilter, orderId = ViewBag.orderId})
    }
    else
    {
        @:<span class="disabled">first</span>
        @Html.Raw(" ");
        @:<span class="disabled">< prev</span>
    }
     
    @if (Model.HasNextPage)
    {
        @Html.ActionLink("next >", "AddItem", new { page = Model.PageNumber + 1, sortOrder = ViewBag.CurrentSort, orderId = ViewBag.orderId})
        @Html.Raw(" ");
        @Html.ActionLink("last", "AddItem", new { page = Model.PageCount, sortOrder = ViewBag.CurrentSort, orderId = ViewBag.orderId})
    }
    else
    {
        @:<span class="disabled">next ></span>
        @Html.Raw(" ")
        @:<span class="disabled">last</span>
    }
</div>
</div>
